package com.kk.xhr.common.pojo;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * 婚姻状态枚举类
 *
 * @author luokexiong
 * @version 1.0 2021/2/14
 * @since 1.0.0
 */
@Getter
@AllArgsConstructor
public enum WedStatusEnum {
    MARRIED((byte) 0),
    UNMARRIED((byte) 1);

    private final byte value;
    private static final Map<Byte, WedStatusEnum> map = Arrays.stream(WedStatusEnum.values())
        .collect(Collectors.toMap(WedStatusEnum::getValue, Function.identity()));

    public static WedStatusEnum from(Byte from) {
        if (null == from) {
            return null;
        }
        return map.getOrDefault(from, UNMARRIED);
    }
}
